<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue-2.4.0.js"></script>
    <style>
        .v-enter,.v-leave-to{
            opacity: 0;
            transform: translateX(150px);
        }
        .v-enter-active,.v-leave-active{
            transition: all .5s;
            /*position: absolute;*/
        }
    </style>
</head>
<body>
<div id="app">
    <a @click.prevent="flag=true" href="">登录</a>
    <a @click.prevent="flag=false" href="">注册</a>
    <login v-if="flag"></login>
    <register v-else="flag"></register>
    <hr>
    <a @click.prevent="comName='login'" href="">登录</a>
    <a @click.prevent="comName='register'" href="">注册</a>
<!--    组件切换-->
    <transition mode="out-in">
        <component :is="comName"></component>
    </transition>
</div>
<script>
    Vue.component('login',{
        template:'<h1>登录组件</h1>'
    })
    Vue.component('register',{
        template: '<h1>注册组件</h1>'
    })
    var vm=new Vue({
        el:'#app',
        data:{
            flag:true,
            comName:'login'
        },
        methods:{

        }
    })
</script>
</body>
</html>